package cn.antho.order.service.impl;

import cn.antho.basic.util.CodeGenerateUtils;
import cn.antho.order.domain.OrderProduct;
import cn.antho.order.dto.ProductOrderDto;
import cn.antho.order.mapper.OrderProductMapper;
import cn.antho.order.service.IOrderProductService;
import cn.antho.basic.service.impl.BaseServiceImpl;
import cn.antho.product.domain.ProductOrderMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author antho
 * @since 2022-11-03
 */
@Service
public class OrderProductServiceImpl extends BaseServiceImpl<OrderProduct> implements IOrderProductService {

    @Autowired
    private OrderProductMapper orderProductMapper;

    @Override
    public void confirm(ProductOrderDto dto) {
        System.out.println(dto);
        OrderProduct orderProduct = orderProductMapper.findById(dto.getOrderProductId());
//        orderProduct.setPaySn(CodeGenerateUtils.generateUnionPaySn());
        orderProduct.setPrice(dto.getPrice());
        orderProduct.setState(1);
        orderProductMapper.update(orderProduct);
    }

    @Override
    public void reject(Long id) {
        OrderProduct orderProduct = orderProductMapper.findById(id);
        orderProduct.setState(-1);
        orderProductMapper.update(orderProduct);
    }
}
